package cn.laixueit.pojo.search;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;
import java.util.Map;

@Data
public class PageRequest implements Serializable {
    private String key;
    private Integer page;

    private String sortBy;
    private Boolean descending;

    private Map<String,String> filter;

    public static final Integer DEFAULT_SIZE = 20;
    private static final  Integer DEFAULT_PAGE = 1;

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public Integer getPage() {
        if(page == null){
            return DEFAULT_PAGE;
        }
        return Math.max(page,DEFAULT_PAGE);
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getSize(){
        return DEFAULT_SIZE;
    }
}
